#include "myQueue.h"


myQueue::myQueue()
 {
    m_size = 0;
    m_capacity = 10;
    m_data = new int[m_capacity];
 }

 myQueue:: ~myQueue()
 {
    delete [] m_data;
 }

int myQueue::reCacapity()
{
    int *tempData = m_data;
    int newCapacity = m_capacity << 1;
    m_data = new int[newCapacity];

    for(int idx = 0;idx < m_size;idx++)
    {
        m_data[idx]  = tempData[idx];
    }

    delete [] tempData;
    m_capacity = newCapacity;
    return 0;
}

void myQueue::push(int data)
{   
    if(m_size == m_capacity)
    {
        reCacapity();
    }
    m_data[m_size++] = data;
}

void myQueue::pop()
{
    for(int idx = 0;idx < m_size-1;idx++)
    {
        m_data[idx] = m_data[idx+1];
    }
    m_size--;
}

int myQueue::front()
{
    return m_data[0];
}

int myQueue::rear()
{
    return m_data[m_size-1];
}

bool myQueue::empty()
{
    return m_size==0;
}

int myQueue::size()
{
    return m_size;
}